package normal;

import java.util.Calendar;
import java.util.Iterator;
import java.util.List;

import util.Tools;

public class StatisName {

    public static void main(String[] args) throws Exception {
        String path = System.getProperty("user.dir");
        List<String> nameList = Tools.readFile(path
                + "/src/testFile/hlm/hongloumeng.txt");
        long startTime = Calendar.getInstance().getTimeInMillis();
        statis(nameList);
        long endTime = Calendar.getInstance().getTimeInMillis();
        System.out.println(Tools.userName.toString());
        System.out.println("开始时间: " + startTime);
        System.out.println("结束时间: " + endTime);
        System.out.println("使用时间(毫秒数):" + (endTime - startTime));
    }

    public static void statis(List<String> nameList) {
        for (int i = 0; i < nameList.size(); i++) {
            Iterator<String> keyOfName = Tools.userName.keySet().iterator();
            while (keyOfName.hasNext()) {
                String name = keyOfName.next();
                Integer cnt = Tools.countMatches(nameList.get(i), name);
                if (cnt > 0) {
                    Tools.userName.put(name, Tools.userName.get(name) + cnt);
                }
            }
        }
    }
}
